/**
 * [addEvent 元素绑定事件]
 * @param {[type]} el      [元素]
 * @param {[type]} event   [事件类型]
 * @param {[type]} handler [func]
 */
export function addEvent (el, event, handler) {
  if (!el) {
    return
  }
  removeEvent(el, event, handler)
  if (el.attachEvent) {
    el.attachEvent('on' + event, handler)
  } else if (el.addEventListener) {
    el.addEventListener(event, handler, true)
  } else {
    el['on' + event] = handler
  }
}

/**
 * [removeEvent 元素移除事件]
 * @param  {[type]} el      [元素]
 * @param  {[type]} event   [事件类型]
 * @param  {[type]} handler [func]
 */
export function removeEvent (el, event, handler) {
  if (!el) {
    return
  }
  if (el.detachEvent) {
    el.detachEvent('on' + event, handler)
  } else if (el.removeEventListener) {
    el.removeEventListener(event, handler, true)
  } else {
    el['on' + event] = null
  }
}
